<template>
  <div class="myself-base">
    <div class="myself-sider">
      <Avatar
        icon="ios-person"
        size="large"
        class="ava"
        :src="userInfo.avatarUrl"
      />
      <div class="title">{{ userInfo.userName }}</div>
      <div class="ex-title">
        <div class="ex-title-col">{{ userInfo.userCode }}</div>
        <div class="ex-title-col">
          {{ userInfo.email ? userInfo.email : '暂无邮箱' }}
        </div>
        <span
          v-for="(item, index) in labelList"
          class="ex-title-label"
          :key="index"
          >{{ item }}</span
        >
      </div>
      <div class="setting" @click="clickSet">
        <Icon type="ios-settings" /> 个人设置
      </div>
      <div class="numCard">
        <Card
          v-for="(item, index) in numList"
          :key="index"
          :style="{ width: '70px', height: '80px' }"
        >
          <div :class="numClass(item.num)">{{ item.num }}</div>
          <div class="card-label">{{ item.label }}</div>
        </Card>
      </div>
      <div class="ex-info"><Icon type="ios-home-outline" />辽宁省大连市</div>
      <div class="ex-info"><Icon type="ios-call" />15042015310</div>
    </div>
    <div class="myself-content">
      <Menu
        mode="horizontal"
        :theme="'light'"
        active-name="1"
        @on-select="selectMenu"
      >
        <MenuItem name="1">
          <Icon type="ios-paper" />
          概括
        </MenuItem>
        <MenuItem name="2">
          <Icon type="ios-people" />
          角色
        </MenuItem>
        <MenuItem name="3">
          <Icon type="ios-construct" />
          绑定
        </MenuItem>
      </Menu>
      <div class="childClass">
        <summarize v-if="showStyle === '1'"></summarize>
        <role v-if="showStyle === '2'"></role>
        <bind v-if="showStyle === '3'"></bind>
      </div>
    </div>
    <edit-user ref="editUser"></edit-user>
  </div>
</template>

<script>
import summarize from './components/summarize.vue'
import role from './components/role.vue'
import bind from './components/bind.vue'
import editUser from '../../sysManagement/userManagement/components/editUser.vue'
export default {
  name: 'mySelf',
  components: { summarize, role, bind, editUser },
  data() {
    return {
      showStyle: '1',
      userInfo: {},
      labelList: ['Java', 'Vue', 'Javascript'],
      numList: [
        { num: 0, label: 'Stars' },
        { num: 100, label: 'Watches' },
        { num: 0, label: 'Followers' },
        { num: 0, label: 'Following' },
      ],
    }
  },
  created() {
    this.init()
  },
  methods: {
    init() {
      this.userInfo = JSON.parse(this.$TOOL.session.get('userInfo'))
    },
    selectMenu(val) {
      this.showStyle = val
    },
    clickSet() {
      console.log('个人设置测试')
      let userId = this.userInfo.userId
      this.$refs.editUser.userId = userId
      this.$refs.editUser.value = true
    },
    numClass(val) {
      if (val != null && val != 0) {
        return 'card-num blue'
      } else {
        return 'card-num'
      }
    },
  },
}
</script>

<style lang="less" scoped>
.myself-base {
  padding: 10px 10px 10px 10px; // padding 上下左右
  height: 100%;
  display: flex;
  justify-content: space-between;
}
.myself-sider {
  height: 100%;
  width: 30%;

  .ava {
    height: 100px;
    width: 100px;
    position: relative;
    text-align: center;
    line-height: 100px;
    left: 50%;
    margin-top: 30px;
    transform: translate(-50%);
    border-radius: 50px;
    box-shadow: 0px 0.5px 1px 0.5px rgba(196, 185, 185, 0.8);
  }
  .title {
    height: 25px;
    margin: 5px 0px;
    text-align: center;
    font-size: 20px;
    color: #40485b;
    line-height: 25px;
    font-weight: bold;
  }
  .ex-title {
    text-align: center;

    .ex-title-col {
      padding: 2px 0px;
      font-size: 12px;
      color: gray;
    }
    .ex-title-label {
      padding: 4px 10px;
      border-radius: 3px;
      color: #6a6a6a;
      background: #efefef;
      margin-left: 5px;
      font-size: 11px;
    }
  }
  .setting {
    width: 100px;
    margin-top: 20px;
    padding: 2px 5px;
    font-size: 12px;
    border: 1px solid #ccc;
    border-radius: 3px;
    text-align: center;
    position: relative;
    left: 50%;
    transform: translate(-50%);
    cursor: pointer;
  }
  .setting:hover {
    color: #3a9fe8;
    box-shadow: 1px 1px 5px 1px rgba(196, 185, 185, 0.8);
  }
  .numCard {
    margin-top: 15px;
    display: flex;
    justify-content: space-evenly;

    .card-num {
      padding-top: 5px;
      text-align: center;
      font-size: 18px;
      font-weight: bold;
    }
    .card-label {
      margin-top: 2px;
      text-align: center;
      font-size: 13px;
    }
    .blue {
      color: #0f8de9;
      cursor: pointer;
    }
    :deep(.ivu-card-body) {
      padding: 10px 0px;
    }
  }
  .ex-info {
    margin-top: 10px;
    margin-left: 20px;
    font-size: 12px;
    color: #8c92a4;
  }
}
.myself-content {
  margin-left: 10px;
  height: 100%;
  width: 70%;

  .childClass {
    overflow-y: auto;
    height: calc(100% - 60px);
  }
}
</style>
